<?php if(!defined('HOST'))die('not access');?>
<script >
    $(document).ready(function(){
        {params};
        var a = $('#veiw_{rand}').bootstable({
            url:js.getajaxurl('lists','ukey','system'),fanye:true,
            columns:[{
                    text:'用户名',dataIndex:'user'
                },{
                    text:'姓名',dataIndex:'name'
                },{
                    text:'性别',dataIndex:'sex'
                },{
                    text:'电话',dataIndex:'mobile'
                },{
                    text:'部门',dataIndex:'deptname'
                },{
                    text:'职位',dataIndex:'ranking'
                }, {
                    text: '操作', dataIndex: 'ukey', renderer: function (v, d) {
                        if (isempt(d.ukey)) {
                            v = "<span style='color:green'>绑定</span>";
                        } else {
                            v = "<span style='color:red'>解绑</span>";
                        }
                        return v;
                    }, renderstyle: function () {
                        return 'word-wrap:break-word;word-break:break-all;white-space:normal;';
                    }
                }],
            itemdblclick:function(d){
                var id = d.id;
                if(isempt(d.ukey)) {
                    layer.confirm('您确定要绑定Ukey吗？', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        js.getChipId();
                        setTimeout(function () {
                            key = $("#ukey").val();
                            if(isempt(key)) {
                                layer.msg('数据有误',{icon: 2});
                                return;
                            }
                            $.ajax({
                                url: "./index.php?a=bind&m=ukey&d=system&ajaxbool=true",
                                data: {id:id,key:key},
                                success: function(obj){
                                    obj = JSON.parse(obj);
                                    if(obj.code == 200){
                                        layer.msg('绑定成功', {icon: 1});
                                        addtabs({num:'gather',url:'system,ukey,bind',icons:'',name:'UKey绑定'});
                                    }else{
                                        layer.msg(obj.msg,{icon: 2});
                                    }
                                }
                            });
                        }, 100);

                    });
                }else{
                    layer.confirm('您确定要解绑Ukey吗？', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        $.get(js.getajaxurl('unbind','ukey','system',{id:id}));
                        layer.msg('解绑成功', {icon: 1});
                        addtabs({num:'gather',url:'system,ukey,bind',icons:'',name:'UKey绑定'});
                    });
                }
            }
        });


        var c = {
            search:function(){
                var s=get('key_{rand}').value;
                a.setparams({key:s},true);
            },
        };
        js.initbtn(c);
    });
</script>


<div>
    <table width="100%"><tr>
            <td>
                <input class="form-control" style="width:300px" id="key_{rand}" placeholder="姓名/部门">
            </td>
            <td nowrap style="padding-left:10px">
                <button class="btn btn-default" click="search" type="button">搜索</button>&nbsp;
            </td>
            <input type="hidden" id="ukey" value=""/>
        </tr>
    </table>
</div>
<div class="blank10"></div>
<div id="veiw_{rand}"></div>